# CMakeExternal CMake configuration file
include(CMakeFindDependencyMacro)

# VARIABLES
SET(USE_SUPERBUILD @BUILD_SUPERBUILD@)  # Set in parent
SET(USE_PROTOBUF @BUILD_PROTOBUF@)  # Set in parent
SET(USE_OPENMP @USE_OPENMP@)  # Modified in a subdirectory
SET(USE_CUDA @USE_CUDA@) # Modified in a subdirectory
SET(USE_FPGA @USE_FPGA@) # Modified in a subdirectory
SET(USE_SYSTEM_EIGEN @USE_SYSTEM_EIGEN@) # Modified in a subdirectory
#SET(USE_SYSTEM_ZLIB @USE_SYSTEM_ZLIB@) # Modified in a subdirectory
SET(USE_SYSTEM_PROTOBUF @USE_SYSTEM_PROTOBUF@) # Modified in a subdirectory
SET(EP_BASE_DIR @EP_BASE_DIR@) # Modified in a subdirectory

# Threads (linux)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
    SET(CMAKE_THREAD_PREFER_PTHREAD TRUE)
    SET(THREADS_PREFER_PTHREAD_FLAG TRUE)
    find_dependency(Threads REQUIRED)
endif()

# OpenMP
if(USE_OPENMP)
    find_dependency(OpenMP REQUIRED)
endif()

# CUDA
if(USE_CUDA)
    enable_language(CUDA)
endif()

# FPGA
if(USE_FPGA)
    find_dependency(OpenCL REQUIRED)
endif()

if(USE_SUPERBUILD)
    list(APPEND CMAKE_MODULE_PATH "${EP_BASE_DIR}")
    if(NOT USE_SYSTEM_EIGEN)
        SET(Eigen3_DIR @Eigen3_DIR@) # Modified in a subdirectory
        list(APPEND CMAKE_PREFIX_PATH ${Eigen3_DIR})
    endif()
#    if(NOT USE_SYSTEM_ZLIB)
#        SET(ZLIB_ROOT_PATH @ZLIB_ROOT@) # Modified in a subdirectory
#        SET(ZLIB_BIN @ZLIB_BIN@) # Modified in a subdirectory
#        list(APPEND CMAKE_PREFIX_PATH ${ZLIB_BIN} ${ZLIB_ROOT_PATH})
#    endif()
endif()
    
# Core dependencies
find_dependency(Eigen3 REQUIRED NO_MODULE)
#find_dependency(ZLIB REQUIRED)

# Protobuf
if(USE_PROTOBUF)
    if(USE_SUPERBUILD AND NOT USE_SYSTEM_PROTOBUF)
        SET(Protobuf_DIR @Protobuf_DIR@) # Modified in a subdirectory
        find_dependency(Protobuf CONFIG REQUIRED HINTS ${Protobuf_DIR})
    else()
        find_dependency(Protobuf REQUIRED)
    endif()
endif()

include("${CMAKE_CURRENT_LIST_DIR}/EDDLTargets.cmake")

# Set default paths
SET(EDDL_ROOT "@CMAKE_INSTALL_PREFIX@")
SET(EDDL_INCLUDE_DIR "@CMAKE_INSTALL_PREFIX@/include")
SET(EDDL_LIBRARIES_DIR "@CMAKE_INSTALL_PREFIX@/lib")
SET(EDDL_LIBRARIES EDDL::eddl)
